<?php


namespace app\admin\controller;


class TestController extends Base
{
    function test(){
        $client = new \GuzzleHttp\Client();
//
//        $response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
//
//        var_dump($response->getStatusCode()); // 200
//        var_dump($response->getHeaderLine('content-type')); // 'application/json; charset=utf8'
//        var_dump($response->getBody()->getContents());// '{"id": 1420053, "name": "guzzle", ...}'


// Send an asynchronous request.
        $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
        $promise = $client->sendAsync($request)->then(function ($response) {
            echo 'I completed! ' . $response->getBody();
        });

        $promise->wait();
    }
}
